package com.swyc.osschat.Common.Base;

import com.swyc.osschat.Chat.Entity.RecentChatEntity;
import com.swyc.osschat.Chat.Service.MessageInfoService;
import com.swyc.osschat.Chat.Service.RecentChatService;
import com.swyc.osschat.Common.Result.Result;
import com.swyc.osschat.Jurisdiction.Entity.UserEntity;
import com.swyc.osschat.Jurisdiction.Service.*;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;

public abstract class BaseController<T extends BaseRelationEntity> {
    @Resource(name = "PermissionService")
    protected PermissionService sysPermissionService;
    @Resource(name = "MenuService")
    protected MenuService sysMenuService;
    @Resource(name = "RoleService")
    protected RoleService sysRoleService;
    @Resource(name = "RoleMenuService")
    protected RoleMenuService sysRoleMenuService;
    @Resource(name = "RolePermissionService")
    protected RolePermissionService sysRolePermissionService;
    @Resource(name = "UserService")
    protected UserService sysUserService;
    @Resource(name = "UserRoleService")
    protected UserRoleService sysUserRoleService;
    @Resource(name = "MessageInfoService")
    protected MessageInfoService messageInfoService;
    @Resource(name = "RecentChatService")
    protected RecentChatService recentChatService;

    protected Logger log = LoggerFactory.getLogger(getClass());

    protected UserEntity getUser() {
        return (UserEntity) SecurityUtils.getSubject().getPrincipal();
    }

    protected Integer getUserId() {
        return getUser().getId();
    }
//    protected abstract Result list(Map<String, Object> params);
    protected abstract Result info(Integer id);
    protected abstract Result save(T t);
    protected abstract Result update(T t);
    protected abstract Result delete(Integer[] ids);
}
